p-token: Add unsafe to transmutable trait - #65
Merged
Conversation
febo
marked this pull request as draft
July 1, 2025 11:17
Contributor
Author
|
CI is failing since it is pulling a new version of mollusk and having some dependencies conflicts. |
joncinque
approved these changes
Jul 1, 2025
joncinque
left a comment
Contributor
There was a problem hiding this comment.
Makes sense to me! Just another consideration for a future PR if you want
Comment on lines
15
to
17
| /// It is up to the type implementing this trait to guarantee that the cast is | ||
| /// safe, i.e., the fields of the type are well aligned and there are no padding | ||
| /// bytes. |
Contributor
There was a problem hiding this comment.
To go with this safety concern, what do you think about specifying that bytes must be on a well-aligned address for T for all the load functions?
Contributor
Author
There was a problem hiding this comment.
Good point, I will add a note on load in a separate PR.
|
LGTM! |
febo
force-pushed
the
febo/unsafe-transmutable
branch
from
July 9, 2025 09:53
5ac906f to
50f80b5
Compare
febo
marked this pull request as ready for review
July 9, 2025 10:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
Transmutabletrait has memory safety implications in its implementation, but it is not marked asunsafe. This is problematic since undefined behaviour can result from an incorrect implementation.Solution
Add
unsafetoTransmutabletrait to make it explicit that the trait has to be carefully implemented.cc: @d0nutptr